using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BaseTemplate
/// </summary>
public class BaseTemplate : Acms.AcmsControls.BaseTemplateControl
{
    protected BaseMaster Master
    {
        get { return Page.Master as BaseMaster; }
    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (!IsValidAge)
        {
            Page.Server.Transfer("~/Gateway.aspx", false);
        }
    }

    public bool IsValidAge
    {
        get
        {
            if (Session["Validated"] != null && Session["Validated"] is bool)
            {
                return (bool)Session["Validated"];
            }
            else if (Request.Cookies["Validated"] != null)
            {
                bool inCookies = false;
                try
                {
                    inCookies = bool.Parse(Request.Cookies["Validated"].Value);
                }
                catch (FormatException)
                {
                }
                if (inCookies)
                {
                    Session["Validated"] = true;
                    return true;
                }
            }
            return false;
        }
    }

}
